import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite' // 按需加载自定义组件
// import { ElementPlusResolver} from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue', 'vue-router'],
      dts: "src/auto-import.d.ts",
      eslintrc: {
        enabled: true
      }
    }),
    Components({
      dts: true,
      dirs: ['src/components'], // 需自动导入自定义组件文件夹
    //   resolvers: [
    //       ElementPlusResolver(),  // ElementPlus按需加载
    //  ] 
    })
  ],
  server: {
    host: '0.0.0.0',
    port: 8000,
    open: true,
    proxy: {
      '/apl': {
        target: '127.0.0.1:3007',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/apl/, '')
      }
    }
  },
  optimizeDeps: {
    include: [
      'vue',
      '@vue/runtime-core',
      '@vue/runtime-dom'
    ]
  },
  resolve: {
    alias: [
      {
        find: '/@',
        replacement: path.resolve(__dirname, 'src'),
      }
    ]
  }

})
